<?php defined('SYSPATH') or die('No direct script access.');

class Model_Discussion extends ORM {

  protected $_table_name = 'discussions';
  protected $_sorting = array('id' => 'desc');

  protected $_has_many = array(
      'discussions_reply' => array('model' => 'discussions_reply', 'foreign_key' => 'to_id'),
      'discussions_category' => array('model' => 'discussions_category', 'foreign_key' => 'category'),
      );

  public function validate_add($array) {

    $validation = Validate::factory($array)
                    ->rule('title', 'not_empty')
                    ->rule('seo_title', 'not_empty')
                    ->rule('text', 'not_empty')
                    ->rule('category', 'not_empty');

    return $validation;
  }

  public function validate_add_edit($array) {

    $validation = Validate::factory($array)
                    ->rule('title', 'not_empty')
                    ->rule('text', 'not_empty')
                    ->rule('category', 'not_empty');

    return $validation;
  }

}
